package com.hualan.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.mapper.PricingTypeMapper;
import com.hualan.pojo.PricingType;
import com.hualan.service.PriceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
 public class PriceTypeImpl implements PriceTypeService {
    @Autowired
    private  PricingTypeMapper pricingTypeMapper;
    @Override
    public PageInfo<PricingType> selectType(Integer pageNum, Integer pageSize, String type) {
        PageHelper.startPage(pageNum,pageSize);
        List<PricingType> pricingTypes = pricingTypeMapper.selectByType(type);
        return new PageInfo<>(pricingTypes);
    }

    @Override
    public int deleteType(Long id) {
        return pricingTypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertType(PricingType record) {
        return pricingTypeMapper.insert(record);
    }

    @Override
    public int updateType(Integer id, String type) {
        return pricingTypeMapper.updateById(id,type);
    }

    @Override
    public int deleteBatch(List<Integer> ids) {
        return pricingTypeMapper.deleteBatch(ids);
    }
}
